package com.lagou.springBootRocketmq;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.data.redis.core.RedisTemplate;

import static com.lagou.springBootRocketmq.cons.Constant.GOODS_COUNT;

@SpringBootApplication
public class RocketMQApplication {

    public static void main(String[] args) {
        SpringApplication.run(RocketMQApplication.class, args);
    }

    @Autowired
    private RedisTemplate redisTemplate;

    // 启动时执行任务CommandLineRunner
    @Bean
    public CommandLineRunner runner() {
        // 初始化商品个数为100
        return args -> {
            redisTemplate.opsForValue().set(GOODS_COUNT, "100");
        };
    }

}
